package main

import (
	"encoding/json"
	"fmt"
)

/*
* Author: JacksonCoder
* CreateTime: 2025/5/17
 */

// stu:  序列化后：{"name":"Nexora","age":93}
//	{"name1":"Nexora","age2":93}
type Student1 struct {
	Name string `json:"name1"`
	Age  int    `json:"age2"`
}

func main(){
	var stu = Student1{Name:"Nexora", Age:93}
	data, err := json.Marshal(stu) // {"name1":"Nexora","age2":93}
	if err != nil{
		fmt.Println("json encode failed errs: ", err)
		return
	}
	fmt.Println("stu: ", string(data))  // {"name1":"Nexora","age2":93}

	var stu2 Student1
	err = json.Unmarshal(data,&stu2) // 反序列化
	fmt.Println("stu2: ", stu2) //  {Nexora 93}

}